package com.lichuang.fruitvarietysm.goods.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lichuang.fruitvarietysm.goods.entity.GoodsSkuAttr;
import com.lichuang.fruitvarietysm.goods.mapper.GoodsSkuAttrMapper;
import com.lichuang.fruitvarietysm.goods.service.impl.GoodsSkuAttrServiceImpl;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shuaihang
 * @since 2019-06-14
 */
@RestController
@RequestMapping("//goods-sku-attr")
public class GoodsSkuAttrController {

    @Autowired
    public GoodsSkuAttrServiceImpl goodsSkuAttrService;
    @Autowired
    public GoodsSkuAttrMapper skuAttrMapper;

    /**
     * 根据商品id，查对应的属性
     * @param goods_id
     * @return
     */
    @RequestMapping("/sSkuAttribute")
    public  List<GoodsSkuAttr> getSkuAttribute(@RequestParam("goods_id")Integer goods_id){
       List<GoodsSkuAttr> goodsSkuAttrs= goodsSkuAttrService.sSkuAttribute(goods_id,-1);
       return goodsSkuAttrs;
    }

    /**
     * 根据id，查找对应的属性值
     * @param id
     * @return
     */
    @RequestMapping("/getSkuValue")
    public  GoodsSkuAttr getSkuValue(@RequestParam("id")Integer id){
        GoodsSkuAttr goodsSkuAttr=new GoodsSkuAttr();
        goodsSkuAttr.setId(id);
        QueryWrapper queryWrapper=new QueryWrapper(goodsSkuAttr);
        GoodsSkuAttr goodsSkuAttr1=skuAttrMapper.selectOne(queryWrapper);
       return  skuAttrMapper.selectOne(queryWrapper);
    }

}
